import requests
from scrapy.http import HtmlResponse


def download(url, timeout=60, retry=0):
    if retry == 3:
        print('下载失败', url)
        return
    try:
        resp = requests.get(url,
                            headers={
                                'User-Agent': 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Mobile Safari/537.36'},
                            timeout=timeout,
                            verify=False
                            )
        return HtmlResponse(
            body=resp.content,
            url=url
        )
    except:
        return download(url, timeout, retry+1)

if __name__ == '__main__':
    url = 'https://www.hao6v.tv/dy/'
    resp = download(url)
    print(resp.text)